package com.nwpu.am.validation;

import com.nwpu.am.annotation.KnowledgeType;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * KnowledgeTypeValidation
 *
 * @author Roy
 * @version 1.0
 * {@code @date} 2024/6/6
 */

public class KnowledgeTypeValidation implements ConstraintValidator<KnowledgeType, Short> {
    /**
     * @param s                          待校验的数据
     * @param constraintValidatorContext
     * @return false：  校验不通过
     * <p>     true：   校验通过
     */
    @Override
    public boolean isValid(Short s, ConstraintValidatorContext constraintValidatorContext) {
        // 提供校验规则
        return s == null || (s >= 0 && s <= 1);
    }

}
